{extend name="public:base"}
{block name="body"}
<body>
		<form class="layui-form layui-form-pane" action="">
			<div class="mainBox">
				<div class="main-container">
                   <div class="layui-row">
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">标题</label>
                                <div class="layui-input-block">
                                    <input type="text" name="title" value="{$info.title|default=''}" lay-verify="required" autocomplete="off"
                                        placeholder="请输入标题" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">上级菜单</label>
                                <div class="layui-input-block">
                                    <select name="pid">
                                        <option value="0">顶级菜单</option>
                                        {volist name="auth_menu" id="vo"}
                                        <option value="{$vo.id}" {present name="info.pid"} {eq name="info.pid" value="$vo['id']"} selected {/eq} {/present}>{$vo.showName}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">标识</label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" value="{$info.name|default=''}" lay-verify="require" autocomplete="off"
                                        placeholder="请输入标识" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">打开方式</label>
                                <div class="layui-input-block">
                                    <input type="text" name="open_type" value="{$info.open_type|default='_iframe'}" lay-verify="require" autocomplete="off"
                                        placeholder="请输入" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">图标</label>
                                <div class="layui-input-block">
                                    <input type="text" id="iconPicker" name="icon" value="{$info.icon|default='layui-icon-circle'}" lay-filter="iconPicker" class="hide">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">类型</label>
                                <div class="layui-input-block">
                                    <select name="type">
                                        <option value="0">菜单栏</option>
                                        <option value="1" {present name="info.type"}{eq name="info['type']" value="1"} seleted {/eq} {/present}>菜单项</option>
                                        <option value="2" {present name="info.type"}{eq name="info['type']" value="2"} seleted {/eq} {/present}>按钮</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">URL地址</label>
                                <div class="layui-input-block">
                                    <input type="text" name="url" value="{$info.url|default=''}" lay-verify="require" autocomplete="off"
                                        placeholder="请输入URL" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">备注</label>
                                <div class="layui-input-block">
                                    <input type="text" name="remark" value="{$info.remark|default=''}"  autocomplete="off"
                                        placeholder="请输入备注" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">菜单</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="is_menu" value="1" lay-skin="switch" lay-text="是|否" {present name="info.is_menu"}{eq name="info['is_menu']" value="1"} checked {/eq} {/present}>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">认证</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="is_auth" value="1" lay-skin="switch" lay-text="是|否" {present name="info.is_auth"}{eq name="info['is_auth']" value="1"} checked {/eq} {else /} checked {/present}>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">登录</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="is_login" value="1" lay-skin="switch" lay-text="是|否" {present name="info.is_login"}{eq name="info['is_login']" value="1"} checked {/eq} {else /} checked {/present}>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-xs12 layui-col-sm6 layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">排序[逆序]</label>
                                <div class="layui-input-block">
                                    <input type="text" name="sort" value="{$info.sort|default='1000'}" lay-verify="require" autocomplete="off"
                                        placeholder="数字越大越靠前" class="layui-input">
                                </div>
                            </div>
                        </div>
                   </div>
                </div>
            </div>
            <div class="bottom">
            <div class="button-container">
                <input type="hidden" name="id" value="{$info.id|default=''}">
                <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="form-save">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="pear-btn pear-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
            </div>
		</form>
	</body>
{/block}
{block name="script"}
<script>
    layui.use(['iconPicker','jquery','form', 'common'], function() {
        let iconPicker = layui.iconPicker;
        let form = layui.form;
        let $ = layui.jquery;
        iconPicker.render({
            elem: '#iconPicker',
            type: 'fontClass',
            search: true,
            page: false,
            limit: 16,
            click: function(data) {
            },
            success: function(d) {
            }
        });
        form.on('submit(form-save)', function(data) {
            $.ajax({
                url: '{:url("edit")}',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function(result) {
                    if (result.code == 1) {
                        layer.msg('操作成功', {
                            icon: 1,
                            time: 1000
                        }, function() {
                            parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页
                            parent.layui.treetable.reload("table-list");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
{/block}
